package com.caigou.controller;

import com.caigou.bean.cms.param.ChannelSpecialIssueParam;
import com.caigou.service.ChannelSpecialIssueService;
import com.caigou.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/specialIssue/")
public class ChannelSpecialIssueController {

    @Resource
    private ChannelSpecialIssueService channelSpecialIssueService;

    @ApiOperation("获取特刊标题信息")
    @RequestMapping("loadChannelSpecialIssueTitle")
    @PreAuthorize("hasAnyAuthority('chakantekanneirong')")
    public Result loadChannelSpecialIssueTitle(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.loadChannelSpecialIssueTitle(param);
    }

    @ApiOperation("获取特刊列表信息")
    @RequestMapping("loadChannelSpecialIssueList")
    @PreAuthorize("hasAnyAuthority('chakantekanneirong')")
    public Result loadChannelSpecialIssueList(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.loadChannelSpecialIssueList(param);
    }

    @ApiOperation("修改开关状态")
    @RequestMapping("updateChannelSpecialIssueStatus")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result updateChannelSpecialIssueStatus(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.updateChannelSpecialIssueStatus(param);
    }

    @ApiOperation("发布特刊数据")
    @RequestMapping("releaseChannelSpecialIssue")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result releaseChannelSpecialIssue(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.releaseChannelSpecialIssue(param);
    }

    @ApiOperation("新增特刊标题信息")
    @RequestMapping("saveChannelSpecialIssueTitle")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result saveChannelSpecialIssueTitle(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.saveChannelSpecialIssueTitle(param);
    }

    @ApiOperation("删除特刊标题信息")
    @RequestMapping("deleteChanelSpecialIssueTitle")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result deleteChanelSpecialIssueTitle(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.deleteChanelSpecialIssueTitle(param);
    }

    @ApiOperation("修改特刊标题信息")
    @RequestMapping("updateChanelSpecialIssueTitle")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result updateChanelSpecialIssueTitle(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.updateChanelSpecialIssueTitle(param);
    }

    @ApiOperation("新增特刊列表")
    @RequestMapping("saveChannelSpecialIssue")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result saveChannelSpecialIssue(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.saveChannelSpecialIssue(param);
    }

    @ApiOperation("删除特刊列表")
    @RequestMapping("deleteChannelSpecialIssue")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result deleteChannelSpecialIssue(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.deleteChannelSpecialIssue(param);
    }

    @ApiOperation("修改特刊列表")
    @RequestMapping("updateChannelSpecialIssue")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result updateChannelSpecialIssue(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.updateChannelSpecialIssue(param);
    }

    @ApiOperation("列表顺序调整")
    @RequestMapping("updateChannelSpecialIssueShowIndex")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result updateChannelSpecialIssueShowIndex(@RequestBody List<ChannelSpecialIssueParam> list){
        return channelSpecialIssueService.updateChannelSpecialIssueShowIndex(list);
    }

    @ApiOperation("清空特刊内容")
    @RequestMapping("cleanChannelSpecialIssue")
    @PreAuthorize("hasAnyAuthority('tekanneirongyangshiguanli')")
    public Result cleanChannelSpecialIssue(@RequestBody ChannelSpecialIssueParam param){
        return channelSpecialIssueService.cleanChannelSpecialIssue(param);
    }
}
